package com.zhuqi;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.concurrent.TimeUnit;

/**
 * @author : ZhuQi
 * @version : 时间:2022/6/21 10:54 版本:
 */
@SpringBootApplication
public class ConfigService {
    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(ConfigService.class, args);
        // 当动态配置刷新时，会更新到 Enviroment 中，因此这里每隔一秒中从 Enviroment 中获取配置
        String name = applicationContext.getEnvironment().getProperty("dog.name");
        String age = applicationContext.getEnvironment().getProperty("dog.age");
        System.err.println("name :" + name + "; age: " + age);
    }
}
